<?php
// +----------------------------------------------------------------------
// |欧阳长空 2018/5/28 学员model
// +----------------------------------------------------------------------

namespace Common\Model;

use Think\Model;

/**
 * 学员基础模型
 */
class StudentModel extends Model
{
	//新增学员
	public function wxAdd($wxuser){
		$map['openid']=$wxuser['openid'];
		$r=M("student_wx")->where($map)->find();
		if(!$r){
			$wxuser['addtime']=date("Y-m-d H:i:s",time());
			$uid=M("student_wx")->add($wxuser);
		}else{
			$openid=$wxuser['openid'];
			unset($wxuser['openid']);
			M("student_wx")->where("openid='".$openid."'")->save($wxuser);
			$uid=$r['id'];
		}
		return $uid;
	}
	//获取学员信息
	public function getStudentInfo($id){
		$map['id']=$id;
		$info=M("student_wx")->where($map)->find();
	} 
	//获取学员的渠道
	public function getStudentChannel($id){
		$map['a.id']=$id;
		$info=M("student_wx a")->join("__PARTNER__ b on a.channelNo=b.channelNo","left")->field("b.*")->where($map)->find();
		return $info;
	}
	
}